/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package project.jpdftools.ui.actionlisteners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import project.jpdftools.ui.logic.JPDFText;
import project.jpdftools.managers.LocalizationManager;

/**
 *
 * @author Mido
 */
public class SpaceAfterAction implements ActionListener {

    private Object component;

    public SpaceAfterAction(Object component) {
        super();
        this.component = component;
    }

    public void actionPerformed(ActionEvent evt) {
        if (component instanceof JPDFText) {
            JPDFText text = (JPDFText) component;
            if (text.getItfSpaceAfter().getText().isEmpty() == false) {
                text.setSpaceAfter(Integer.valueOf(text.getItfSpaceAfter().getText()));
                // hide popup menu
                text.getMenu().setVisible(false);
            } else {
                JOptionPane.showMessageDialog(null, LocalizationManager.getCurrent_resource().getString("JPDFTEXT_SPCAE_AFTER_TEXT_ERROR"),
                        LocalizationManager.getCurrent_resource().getString("ERROR"), 0);
            }
        }
    }
}
